# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=atop
pkgver=2.11.0
pkgrel=0
pkgdesc="Resource-specific view of processes"
url="https://www.atoptool.nl/"
arch="all"
license="GPL-2.0-or-later"
makedepends="glib-dev linux-headers ncurses-dev zlib-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tgz::https://www.atoptool.nl/download/atop-$pkgver.tar.gz
	atop-daily-bb.patch
	make-cron-background.patch
	atop.initd
	"
options="!check"

prepare() {
	default_prepare

	sed -i -e '/DEFPATH/d' Makefile

	cp "$srcdir"/atop.initd atop.init
	chmod a+rx atop.init
}

build() {
	make
}

package() {
	make DESTDIR="$pkgdir" \
		INIPATH=/etc/init.d \
		SCRPATH=/etc/periodic/daily \
		sysvinstall
	rm -fr "$pkgdir"/etc/cron.d
	mv "$pkgdir"/etc/periodic/daily/atop.daily \
		"$pkgdir"/etc/periodic/daily/atop
}

sha512sums="
f43881fcc9fa8bfe6837bd8228b9fc7fc7679f84e51af80ab5e9f89915e254fbf6e24c7bf78c22814d8d9db5b012d46ca75ff5abe1dfde3b51d94fa29fed077a  atop-2.11.0.tgz
664225450074962aac0e13484c9b2feaf08620bbe1e0f9c5dc1b02f1ecd315224cd04df53134f2d107210fc9223a64d8885ae70d33d0663c2335fa6d46f6ddfd  atop-daily-bb.patch
e563894eceadf63ff153714829218b8f78dd21a129b90817960bdb4452768f41ed884dc9967f94b979e42f04d6434fcbd423bcf1651976a5ad60c34b206ce7e9  make-cron-background.patch
efbf36d933a8be90ebf2fd54a188cd1c9bc9b8d87755625aba85831a83f3a087dbe6e953f7ce36b38d9909b9ab747e0e9186ad0e85382d5b4e8690c9cfdc0d40  atop.initd
"
